import React from "react";
import axios from "axios";
import { useSearchParams } from "react-router-dom";
const Index = () => {
  const [searchParams] = useSearchParams();
  const order_id = +new Date();
  const price = searchParams.get("price");
  const title = "这是一个订单";
  const handlePay = async () => {
    const resp = await axios.post("/api/pay", { order_id, price, title });
    window.location.href = resp.data.data;
  };
  return (
    <div>
      <div>订单号: {order_id}</div>
      <div>订单标题: {title}</div>
      <div>订单金额: {price}</div>
      <button onClick={handlePay}>付款</button>
    </div>
  );
};
export default Index;
